/**
 * 
 */
package com.local.redis.redisbase;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import redis.clients.jedis.Jedis;

/**
 * @author Administrator
 *
 */
public class RedisMap {
	private static final Jedis JEDIS = new Jedis("localhost");
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		//map存值
		Map<String,String> map = new HashMap<String,String>();
		map.put("aac001", "1000");
		map.put("aac003", "张三");
		map.put("aac004", "男");
		map.put("aac005", "汉族");
		map.put("aac006", "20000101");
		map.put("aac009", "鹿城区");
		JEDIS.hmset("map",map);
			
		//取值
		Iterator<String> iter=JEDIS.hkeys("map").iterator(); 
		while (iter.hasNext()){// .hahNext返回的是boolean类型
			String key = iter.next();               
			System.out.println(key+":"+JEDIS.hmget("map",key)); 
		}
		
		System.out.println(JEDIS.exists("map")); //检查是否存在key为map的值
		
		JEDIS.hdel("map","aac009");//删除操作
		System.out.println(JEDIS.hmget("map","aac009")); //已删除对应key,返回null
		
		System.out.println(JEDIS.hkeys("map")); //hkeys("key") 返回map中对应的key值
		System.out.println(JEDIS.hvals("map")); //hvals("key") 返回map中对应的value值
		System.exit(0);
	} 

}
